package o;

import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.card.gamereserve.bean.OrderAppCardBean;
import com.huawei.appgallery.foundation.store.bean.detail.DetailResponse;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSSelector;
import com.huawei.appgallery.foundation.ui.css.CSSStyleSheet;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.Layout;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.LayoutData;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.jsonkit.api.JsonBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse.TabInfo;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailColumnTabBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailHeadBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailHiddenBean;
import com.huawei.appmarket.service.appdetail.view.AppDetailFragmentProtocol.Request;
import com.huawei.appmarket.service.appdetail.view.card.DetailHeadCard;
import com.huawei.appmarket.service.appdetail.view.card.DetailHiddenCard;
import com.huawei.appmarket.service.reserve.game.card.ReserveHiddenCard;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;

public class drr extends dri {
    private List<TabInfo> ʻ = new ArrayList();
    private String ʼ = null;
    private String ʽ = null;
    private DetailHiddenBean ˊ = null;
    protected Map<String, b> ˋ = new LinkedHashMap();
    private DetailHeadBean ˏ = null;
    private Request ˏॱ;
    private OrderAppCardBean ॱ = null;
    private String ॱॱ = null;
    private boolean ᐝ = false;

    public static class b {
        private String ʻ;
        private int ʼ;
        private CSSRule ʽ;
        public drl ˊ;
        protected List<JsonBean> ˋ = new ArrayList();
        private String ˎ;
        private CSSStyleSheet ˏ;
        private String ॱ;
        private String ᐝ;

        public b(String str, drl o_drl, int i, List<CardBean> list) {
            ˏ(str, o_drl, i, list);
        }

        public void ॱ(CSSStyleSheet cSSStyleSheet, String str) {
            if (cSSStyleSheet != null) {
                this.ʽ = new CSSSelector(str).getRule(cSSStyleSheet.getRootRule());
                this.ˏ = cSSStyleSheet;
                this.ˎ = str;
            }
        }

        public String ॱ() {
            return this.ॱ;
        }

        public void ˎ(String str) {
            this.ॱ = str;
        }

        public CSSStyleSheet ˎ() {
            return this.ˏ;
        }

        public String ˏ() {
            return this.ˎ;
        }

        public CSSRule ˊ() {
            return this.ʽ;
        }

        public String ˋ() {
            return this.ʻ;
        }

        public void ˋ(String str) {
            this.ʻ = str;
        }

        protected void ˏ(String str, drl o_drl, int i, List<CardBean> list) {
            this.ᐝ = str;
            this.ˊ = o_drl;
            this.ʼ = i;
            ˋ((List) list);
        }

        public String ᐝ() {
            return this.ᐝ;
        }

        public List<JsonBean> ʼ() {
            return this.ˋ;
        }

        public int ʽ() {
            return this.ʼ;
        }

        public void ˋ(List<CardBean> list) {
            if (list != null) {
                this.ˋ.addAll(list);
            }
        }
    }

    public Request ˊ() {
        return this.ˏॱ;
    }

    public void ˏ(Request request) {
        this.ˏॱ = request;
    }

    public static boolean ˊ(drr o_drr, BaseRequest o_cvu, ResponseBean responseBean) {
        if (responseBean.getResponseCode() != 0) {
            return false;
        }
        String ˎ;
        if (o_cvu instanceof cfv) {
            ˎ = ((cfv) o_cvu).ˎ();
        } else {
            ˎ = null;
        }
        DetailResponse detailResponse = (DetailResponse) responseBean;
        List<Layout> ʻॱ = detailResponse.ʻॱ();
        List<LayoutData> ᐝॱ = detailResponse.ᐝॱ();
        o_drr.ˎ = CSSStyleSheet.parse(detailResponse.ॱˎ());
        Collection ˎ2 = detailResponse.ˎ();
        if (ˎ2 != null) {
            o_drr.ʻ.clear();
            o_drr.ʻ.addAll(ˎ2);
        }
        if (!(ʻॱ == null || ʻॱ.isEmpty())) {
            for (Layout layout : ʻॱ) {
                b ˊ = o_drr.ˊ(String.valueOf(layout.ˋ()), layout.ˎ(), layout.ॱ(), null);
                if (ˊ != null) {
                    ˊ.ॱ(o_drr.ˎ, layout.ˏ());
                    ˊ.ˎ(ˎ);
                }
            }
        }
        if (!(ᐝॱ == null || ᐝॱ.isEmpty())) {
            for (LayoutData layoutData : ᐝॱ) {
                if (layoutData.ˋ() == null) {
                    Logger.ˋ("DetailDataProvider", "layoutdata.datalist is null, layoutid:" + layoutData.ˎ());
                } else {
                    b ˊ2 = o_drr.ˊ(String.valueOf(layoutData.ˎ()));
                    if (ˊ2 != null) {
                        ListIterator listIterator = layoutData.ˋ().listIterator(layoutData.ˋ().size());
                        while (listIterator.hasPrevious()) {
                            CardBean cardBean = (CardBean) listIterator.previous();
                            if (!(cardBean instanceof BaseDistCardBean)) {
                                break;
                            }
                            ˊ(layoutData, listIterator, (BaseDistCardBean) cardBean);
                        }
                        ˊ2.ˋ(layoutData.ˋ());
                    }
                }
            }
        }
        return true;
    }

    private static void ˊ(LayoutData<CardBean> layoutData, ListIterator<CardBean> listIterator, BaseDistCardBean baseDistCardBean) {
        int i = 0;
        if (layoutData.ˊ() == 1) {
            i = 1;
        }
        if (layoutData.ॱ() == 1) {
            i |= 2;
        }
        if (!baseDistCardBean.ˋ(i)) {
        }
    }

    public b ˊ(String str, String str2, int i, List<CardBean> list) {
        drl ˎ = drp.ˎ(str2);
        if (ˎ == null) {
            return null;
        }
        if (ˎ instanceof DetailHeadCard) {
            this.ʼ = str;
        } else if (ˎ instanceof DetailHiddenCard) {
            this.ॱॱ = str;
        } else if (ˎ instanceof ReserveHiddenCard) {
            this.ʽ = str;
        }
        b bVar = new b(str, ˎ, i, list);
        bVar.ˋ(str2);
        this.ˋ.put(str, bVar);
        return bVar;
    }

    public b ˊ(String str) {
        return (b) this.ˋ.get(str);
    }

    public int ॱ() {
        return this.ˋ.size();
    }

    public b[] ˏ() {
        return (b[]) this.ˋ.values().toArray(new b[this.ˋ.size()]);
    }

    public OrderAppCardBean ˎ() {
        if (this.ॱ != null) {
            return this.ॱ;
        }
        b bVar = (b) this.ˋ.get(this.ʽ);
        if (bVar == null) {
            return null;
        }
        List ʼ = bVar.ʼ();
        if (ʼ == null || ʼ.size() <= 0) {
            return null;
        }
        JsonBean jsonBean = (JsonBean) ʼ.get(0);
        if (!(jsonBean instanceof OrderAppCardBean)) {
            return null;
        }
        OrderAppCardBean orderAppCardBean = (OrderAppCardBean) jsonBean;
        orderAppCardBean.ˏ(4);
        this.ॱ = orderAppCardBean;
        return orderAppCardBean;
    }

    public DetailHeadBean ˋ() {
        if (this.ˏ != null) {
            return this.ˏ;
        }
        b bVar = (b) this.ˋ.get(this.ʼ);
        if (bVar == null) {
            return null;
        }
        List ʼ = bVar.ʼ();
        if (ʼ == null || ʼ.size() <= 0) {
            return null;
        }
        JsonBean jsonBean = (JsonBean) ʼ.get(0);
        if (!(jsonBean instanceof DetailHeadBean)) {
            return null;
        }
        DetailHeadBean detailHeadBean = (DetailHeadBean) jsonBean;
        this.ˏ = detailHeadBean;
        return detailHeadBean;
    }

    public DetailHiddenBean ᐝ() {
        if (this.ˊ != null) {
            return this.ˊ;
        }
        b bVar = (b) this.ˋ.get(this.ॱॱ);
        if (bVar == null) {
            return null;
        }
        List ʼ = bVar.ʼ();
        if (ʼ == null || ʼ.size() <= 0) {
            return null;
        }
        JsonBean jsonBean = (JsonBean) ʼ.get(0);
        if (!(jsonBean instanceof DetailHiddenBean)) {
            return null;
        }
        DetailHiddenBean detailHiddenBean = (DetailHiddenBean) jsonBean;
        this.ˊ = detailHiddenBean;
        return detailHiddenBean;
    }

    public List<DetailColumnTabBean> ʽ() {
        List<DetailColumnTabBean> arrayList = new ArrayList();
        if (this.ʻ.isEmpty()) {
            return null;
        }
        for (TabInfo tabInfo : this.ʻ) {
            if (!(tabInfo.ᐝ() == null || tabInfo.ʼ() == null)) {
                if (dro.ˋ(tabInfo.ʼ()) != null || tabInfo.ʼ().startsWith("forum|forum_detail_app")) {
                    DetailColumnTabBean detailColumnTabBean = new DetailColumnTabBean();
                    detailColumnTabBean.ˋ(tabInfo.ᐝ());
                    detailColumnTabBean.ˏ(tabInfo.ʼ());
                    detailColumnTabBean.ˊ(tabInfo.ॱॱ());
                    arrayList.add(detailColumnTabBean);
                }
            }
        }
        return arrayList;
    }

    public void ˏ(boolean z) {
        this.ᐝ = z;
    }
}
